//#pragma GCC optimize("Ofast")
//#pragma GCC optimize(3)
//#pragma GCC optimize(3,3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
typedef long long int
bool st;
int read(int &x){
    x=0;
    char c=0;
    bool f=1;
    while(!isdigit(c)){
        f&=(c!='-');
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    x=(f?x:-x);
}
const int N=1e6+5;
int n;
int x[N],r[N];
//int a[N],cnt[N];
multiset<int>a;
//vector<int>a;
void print_a(){
    cout<<"a: \n";
    for(int i:a){
        cout<<i<<" ";
    }
    cout<<endl;
}
bool attak[N];
void print_attak(){
    cout<<"attak: \n";
    for(int i=1;i<=n;i++){
        cout<<attak[i]<<" ";
    }
    cout<<endl;
}
bool isa[N];
void print_isa(){
    cout<<"isa: \n";
    for(int i=1;i<=n;i++){
        cout<<isa[i]<<" ";
    }
    cout<<endl;
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    memset(attak,1,sizeof attak);
    memset(isa,1,sizeof isa);
    read(n);
    //cout<<"n: "<<n<<endl;
    for(int i=1;i<=n;i++){
        scanf("%d",x+i);
        r[i]=x[i];
        //read(x[i]);
        a.insert(x[i]);
        //cout<<"i: "<<i<<" x: "<<x[i]<<endl;
        //cnt[a[i]]++;
        //a.push_back(x);
    }
    //sort(a.begin(),a.end());
    //sort(a+1,a+n+1);
    //print_a();
    auto b=a.begin();
    for(int i=1;i<=n;i++){
        x[i]=*b;
        b++;
    }
    int num=n;
    for(int i=1;i<=n;i++){
        cout<<"i: "<<i<<endl;
        if(isa[i]==0){
            continue;
        }
        auto res=upper_bound(a.begin(),a.end(),x[i]);
        if(res!=a.end() && *res>x[i]){
            int cnt=a.count(x[i]);
            int tot=min(a.count(x[i]),a.count(*res));
            //cout<<"i: "<<i<<" tot: "<<tot<<endl;
            auto t=a.find(x[i]);
            auto res1=res;
            int dead=i;
            int alive=i+cnt;
            while(tot--){
                //cout<<"dead: "<<dead<<" alive: "<<alive<<" cnt: "<<cnt<<endl;
                if(attak[alive]==0){
                    continue;
                }
                if(isa[dead]=0){
                    continue;
                }
                if(alive>n){
                    break;
                }
                attak[dead]=0;
                attak[alive]=0;
                isa[dead]=0;
                a.erase(t);
                //a.erase(res1);
                t=a.find(x[i]);
                res1=a.find(*res);
                //print_attak();
                //print_isa();
                num--;
                dead++;
                alive++;
            }
            //a.erase(a.find(x[i]));
            //cout<<"num: "<<num<<endl;
            //print_a();
        } else{
            break;
        }
    }
    printf("%d",num);
    fclose(stdin);
    fclose(stdout);
    return 0;
}
